<template>
    <div class="jobcommon EditResumeInfo">
        <div class="smalbox">
            <div class="backnavjob">
                <h1 @click="closejibenxinxi('close')">
                    <img
                        data-v-61dd7a3d=""
                        src="../../assets//newimg/index/icon_right_h.png"
                        alt=""
                    />
                </h1>
                <h2>
                    <span>简历-获得证书</span>
                </h2>
                <h3></h3>
            </div>

            <div class="list_height plist-txt notarrow">
                <div class="pic"></div>
                <div class="tit font14">
                    证书名称<span class="font_red_light">*</span>
                </div>
                <div class="describe font13">
                    <input
                        type="text"
                        id="name"
                        placeholder="请输入证书名称"
                        value=""
                        v-model="info.name"
                    />
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>
            <div
                class="list_height plist-txt qs-relative js-actionParent"
                @click="beginKey = !beginKey"
            >
                <div class="abAct js-showActionSheet"></div>
                <div class="pic"></div>
                <div class="tit font14">
                    获得时间<span class="font_red_light">*</span>
                </div>
                <div class="describe font13 qs-temp-date" data-type="start">
                    <span class="f-date-txt-start"
                        >{{ info.year }}年-{{ info.month }}月</span
                    >
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>

            <div class="j_newbutton">
                <div class="j_newbtn" @click="closejibenxinxi()">保存</div>
            </div>
            <!-- 开始时间 -->
            <component
                :is="'TimePicker'"
                v-if="beginKey"
                @changeTime="beginTimePicker"
                :year="info.year"
                :month="info.month"
                @closeTimePciker="beginKey = false"
            ></component>
            <div class="zhanwei"></div>
        </div>
    </div>
</template>

<script>
import { axiosPost } from '../../axios';
import { Toast } from 'vant';
export default {
    name: '',
    props: ['dataProps'],
    data() {
        return {
            // 时间相关
            beginKey: false,

            info: {
                id: '',
                month: '',
                name: '',
                pid: '',
                year: '',
            },
        };
    },
    computed: {},
    mounted() {
        // 设置传递过来的数据
        if (this.dataProps) {
            this.info = this.dataProps;
        }
    },
    methods: {
        closejibenxinxi(type) {
            if (type) {
                this.$emit('closeProps', { type: 7, key: false });
                return;
            }
            if (!this.info.name) {
                return Toast({
                    message: '请输入证书名称',
                    duration: 2000,
                });
            }

            if (!this.info.year) {
                return Toast({
                    message: '请选择开始时间',
                    duration: 2000,
                });
            }

            axiosPost('/apis/resume/edit_certificate', this.info, (res) => {
                Toast({
                    message: res.msg,
                    duration: 2000,
                });
                if (res.status != 1) {
                    return;
                }
                this.$emit('closeProps', { type: 7, key: true });
            });
        },
        // 开始时间
        beginTimePicker(data) {
            this.info.year = data.y;
            this.info.month = Number(data.m);
        },
    },
};
</script>
<style lang="css" src="../../assets/css/jobperson.css"></style>
<style lang="less" scope></style>
